﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using EDMDesigner.Designer.Controls.Relations;

namespace EDMDesigner.Designer.BindingConverter
{
    public class AssociationToVisibleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Association association = (Association)value;
            bool visible = association.FromTypeDesigner != association.ToTypeDesigner || association.FromTypeDesigner.IsExpanded;
            if (visible && parameter == null)
                visible = association.FourPoints;
            return visible ? Visibility.Visible : Visibility.Collapsed;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
